home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / mus / play / multiplsr.lha / flash.asm < prev    next >
Assembly Source File  |  1992-09-14  |  14KB  |  499 lines

  1. * MultiPlayer
  2. * Copyright (C) 1992 Bryan Ford
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. *
  18. * I (the author of MultiPlayer) can be contacted on the Internet at
  19. * "bryan.ford@m.cc.utah.edu".  See "Player.doc" for other addresses.
  20. *
  21. * $Id: flash.asm,v 4.2 92/06/21 11:14:12 BAF Exp Locker: BAF $
  22. *
  23.  
  24.         include "exec/types.i"
  25.         include "exec/nodes.i"
  26.         include "exec/tasks.i"
  27.         include "exec/semaphores.i"
  28.         include "exec/libraries.i"
  29.         include "exec/funcdef.i"
  30.         include "exec/exec_lib.i"
  31.         include "graphics/gfx.i"
  32.         include "graphics/rastport.i"
  33.         include "graphics/gfx_lib.i"
  34.         include "dos/dos.i"
  35.         include "bry/macros.i"
  36.         include "player.i"
  37.  
  38. FLASHYSTACKSIZE equ     1024
  39.  
  40.         xdef    _flashyupdate
  41.         xdef    _flashytask,_flashysem
  42.         xdef    _spectrum,_flashactive,scopechandata,_scopeinterval,_flashytaskptr
  43.         xdef    notetab,scrollmod,scrolllines,scrollline
  44.  
  45.  
  46.         xref    _LinkerDB,_SysBase,_GfxBase
  47.         xref    _spectrumrastport,_spectrumboxleft,_spectrumboxtop
  48.         xref    _scoperastport,_scopeboxlleft,_scopeboxrleft,_scopeboxtop
  49.         xref    _qscoperastport,_qscopeboxlx,_qscopeboxrx,_qscopeboxty,_qscopeboxby
  50.         xref    _noterastport,_noteboxleft,_noteboxtop
  51.         xref    _flashactive,_spectrum
  52.  
  53.         code    text
  54.  
  55. *** _flashyupdate - Code executed in Flashy task
  56. _flashyupdate
  57.         lea     _LinkerDB,a4
  58.  
  59. \loop
  60.         ml      _SysBase(a4),a6
  61.  
  62.         ml      #SIGBREAKF_CTRL_F,d0    ; Wait for an update signal
  63.         jl      Wait
  64.  
  65.         lea     _flashysem,a0           ; Don't want to get killed while we're drawing
  66.         jl      ObtainSemaphore
  67.  
  68.         ml      _GfxBase(a4),a6
  69.         mq      #0,d7
  70.  
  71.         tst.l   _spectrumrastport
  72.         bz.b    \nospectrum
  73.         bsr     dospectrum
  74. \nospectrum
  75.  
  76.         tst.l   _scoperastport          ; See if stereo scope is active
  77.         bz      \noscope
  78.         cq      d2
  79.  
  80.         lea     scopechandata(a4),a0    ; Left scope
  81.         lea     scopechandata+scd_SIZEOF*3(a4),a1
  82.         mw      _scopeboxlleft,d2
  83.         bsr     doscope
  84.  
  85.         mw      _scopeboxrleft,d2       ; Right scope
  86.         lea     scopechandata+scd_SIZEOF*1(a4),a0
  87.         lea     scopechandata+scd_SIZEOF*2(a4),a1
  88.         bsr     doscope
  89. \noscope
  90.  
  91.         tst.l   _qscoperastport         ; See if quadrascope is active
  92.         bz      \noqscope
  93.         cq      d2
  94.         cq      d3
  95.  
  96.         mw      _qscopeboxlx,d2         ; Channel 0 scope (top-left)
  97.         mw      _qscopeboxty,d3
  98.         lea     scopechandata(a4),a0
  99.         bsr     doqscope
  100.  
  101.         mw      _qscopeboxrx,d2         ; Channel 1 scope (top-right)
  102.         mw      _qscopeboxty,d3
  103.         lea     scopechandata+scd_SIZEOF*1(a4),a0
  104.         bsr     doqscope
  105.  
  106.         mw      _qscopeboxrx,d2         ; Channel 2 scope (bottom-right)
  107.         mw      _qscopeboxby,d3
  108.         lea     scopechandata+scd_SIZEOF*2(a4),a0
  109.         bsr     doqscope
  110.  
  111.         mw      _qscopeboxlx,d2         ; Channel 3 scope (bottom-left)
  112.         mw      _qscopeboxby,d3
  113.         lea     scopechandata+scd_SIZEOF*3(a4),a0
  114.         bsr     doqscope
  115.  
  116. \noqscope
  117.  
  118.         tst.l   _noterastport           ; Draw the note scroller
  119.         bz.b    \nonote
  120.         bsr     donote
  121. \nonote
  122.  
  123.         and.b   d7,_flashactive(a4)
  124.  
  125.         lea     _flashysem,a0           ; Don't want to get killed while we're drawing
  126.         ml      _SysBase(a4),a6
  127.         jl      ReleaseSemaphore
  128.  
  129.         bra     \loop                   ; Infinite loop
  130.  
  131. *** dospectrum - Draw the spectrum display
  132. dospectrum
  133.         lea     specplane0,a0
  134.         lea     specplane1,a1
  135.         mq      #SPECTRUMHEIGHT-1,d0
  136.         mq      #0,d2
  137.         mq      #$7f,d3
  138.         mq      #$fffffffe,d4
  139. \plotspecline
  140.         lea     _spectrum(a4),a2
  141.         mq      #SPECTRUMRES-1,d1
  142. \plotspecbyte
  143.         cmp.b   (a2)+,d0
  144.         blo.b   \plotspecbar
  145.         mb      d2,(a0)+
  146.         mb      d2,(a1)+
  147.         dbra    d1,\plotspecbyte
  148.         dbra    d0,\plotspecline
  149.         bra.b   \plotspecout
  150. \plotspecbar
  151.         mb      d3,(a0)+
  152.         mb      d4,(a1)+
  153.         dbra    d1,\plotspecbyte
  154.         dbra    d0,\plotspecline
  155. \plotspecout
  156.  
  157.         lea     spectrumbitmap,a0       ; Copy the new display
  158.         cq      d0
  159.         cq      d1
  160.         ml      _spectrumrastport,a1
  161.         mb      #3,rp_Mask(a1)
  162.         cq      d2
  163.         mw      _spectrumboxleft,d2
  164.         cq      d3
  165.         mw      _spectrumboxtop,d3
  166.         mq      #SPECTRUMWIDTH-1,d4
  167.         addq.w  #1,d4
  168.         mq      #SPECTRUMHEIGHT,d5
  169.         mw      #$0c0,d6
  170.         jl      BltBitMapRastPort
  171.  
  172.         mq      #0,d1
  173.         lea     _spectrum(a4),a0
  174.         mq      #SPECTRUMRES-1,d0
  175. \decspec
  176.         tst.b   (a0)+
  177.         bz.b    \decspecz
  178.         mq      #-1,d7
  179.         subq.b  #3,-1(a0)
  180.         bpl.b   \decspecz
  181.         clr.b   -1(a0)
  182. \decspecz
  183.         dbra    d0,\decspec
  184.         rts
  185.  
  186. *** doscope - Draw one display in the stereo scope
  187. doscope
  188.         cq      d0
  189.  
  190.         tst.w   scd_len(a0)             ; First channel in use?
  191.         bz.b    \noch0
  192.         mw      scd_pos(a0),d0          ; Find first channel's data
  193.         ml      scd_sample(a0),a0
  194.         add.l   d0,a0
  195.         mq      #-1,d7                  ; Flag that there's something to display
  196.         bra.b   \hasch0
  197. \noch0
  198.         lea     zeros,a0
  199. \hasch0
  200.  
  201.         tst.w   scd_len(a1)             ; Second channel in use?
  202.         bz.b    \noch1
  203.         mw      scd_pos(a1),d0
  204.         ml      scd_sample(a1),a1
  205.         add.l   d0,a1
  206.         mq      #-1,d7                  ; Flag that there's something to display
  207.         bra.b   \hasch1
  208. \noch1
  209.         lea     zeros,a1
  210. \hasch1
  211.  
  212. \startscan
  213.         lea     scopeplane,a3           ; Clear the bitplane first
  214.         mq      #(SCOPEWIDTH/8*SCOPEHEIGHT)/16-1,d0
  215.         cq      d1
  216. \clear
  217.         ml      d1,(a3)+
  218.         ml      d1,(a3)+
  219.         ml      d1,(a3)+
  220.         ml      d1,(a3)+
  221.         dbra    d0,\clear
  222.  
  223.         mq      #SCOPEWIDTH/8-1,d0      ; Plot the scope
  224.         lea     -SCOPEWIDTH/8*SCOPEHEIGHT/2(a3),a2
  225.         mw      #$fff8,d5
  226. \scopebyte
  227.         mq      #8-1,d1
  228. \scopebit
  229.         mb      (a0)+,d3
  230.         ext.w   d3
  231.         mb      (a1)+,d4
  232.         ext.w   d4
  233.         add.w   d4,d3
  234.         asr.w   #1,d3
  235.         and.w   d5,d3
  236.         bset.b  d1,0(a2,d3.w)
  237.         dbra    d1,\scopebit
  238.         addq.w  #1,a2
  239.         dbra    d0,\scopebyte
  240.  
  241.         lea     scopebitmap,a0          ; Copy the new scope display
  242.         cq      d0
  243.         cq      d1
  244.         ml      _scoperastport,a1
  245.         mb      #1,rp_Mask(a1)
  246.         cq      d3
  247.         mw      _scopeboxtop,d3
  248.         mq      #SCOPEWIDTH,d4
  249.         mq      #SCOPEHEIGHT,d5
  250.         mw      #$0c0,d6
  251.         jl      BltBitMapRastPort
  252.  
  253.         rts
  254.  
  255. *** doqscope - Draw one display in the quadrascope
  256. doqscope
  257.         cq      d0
  258.  
  259.         tst.w   scd_len(a0)             ; First channel in use?
  260.         bz.b    \noch0
  261.         mw      scd_pos(a0),d0          ; Find first channel's data
  262.         ml      scd_sample(a0),a0
  263.         add.l   d0,a0
  264.         mq      #-1,d7                  ; Flag that there's something to display
  265.         bra.b   \hasch0
  266. \noch0
  267.         lea     zeros,a0
  268. \hasch0
  269.  
  270. \startscan
  271.         lea     scopeplane,a3           ; Clear the bitplane first
  272.         mq      #(SCOPEWIDTH/8*SCOPEHEIGHT)/16-1,d0
  273.         cq      d1
  274. \clear
  275.         ml      d1,(a3)+
  276.         ml      d1,(a3)+
  277.         ml      d1,(a3)+
  278.         ml      d1,(a3)+
  279.         dbra    d0,\clear
  280.  
  281.         mq      #SCOPEWIDTH/8-1,d0      ; Plot the scope
  282.         lea     -SCOPEWIDTH/8*SCOPEHEIGHT/2(a3),a2
  283.         mw      #$fff8,d5
  284. \scopebyte
  285.         mq      #8-1,d1
  286. \scopebit
  287.         mb      (a0)+,d4
  288.         ext.w   d4
  289.         and.w   d5,d4
  290.         bset.b  d1,0(a2,d4.w)
  291.         dbra    d1,\scopebit
  292.         addq.w  #1,a2
  293.         dbra    d0,\scopebyte
  294.  
  295.         lea     scopebitmap,a0          ; Copy the new scope display
  296.         cq      d0
  297.         cq      d1
  298.         ml      _qscoperastport,a1
  299.         mb      #1,rp_Mask(a1)
  300.         mq      #SCOPEWIDTH,d4
  301.         mq      #SCOPEHEIGHT,d5
  302.         mw      #$0c0,d6
  303.         jmp     _LVOBltBitMapRastPort(a6)
  304.  
  305. *** donote - Draw the note scroller
  306.  
  307. dolong  macro
  308.         tst.w   (a0)+
  309.         sne.b   d0
  310.         mw      (a0)+,d7
  311.         and.w   d6,d7
  312.         sne.b   d7
  313.         and.b   d5,d7
  314.         mb      d7,(a1)+
  315.         mb      d0,(a1)+
  316.         mb      d0,(a1)+
  317.         mb      d7,(a1)+
  318.         endm
  319.  
  320. donote
  321.         ml      notetab(a4),a0
  322.         lea     noteplane,a1
  323.         mw      scrollline(a4),d0
  324.         mw      scrolllines(a4),d1
  325.         cmp.w   d1,d0
  326.         blo.b   \lineok
  327.         cq      d0
  328. \lineok
  329.         cmp.w   oldscrollline(a4),d0
  330.         beq.b   \sameline
  331.         mw      d0,oldscrollline(a4)
  332.  
  333.         mq      #16,d4
  334.         mw      #NOTEHEIGHT/2-1,d2
  335.         sub.w   #NOTEHEIGHT/4,d0
  336.         bmi.b   \topblank
  337.         beq.b   \topexact
  338.  
  339. \topchopped                             ; Top part of note table is chopped off
  340.         mw      scrollmod(a4),d3
  341.         add.w   d4,d3
  342. \topchoploop
  343.         add.w   d3,a0
  344.         subq.w  #1,d1
  345.         subq.w  #1,d0
  346.         bnz.b   \topchoploop
  347.         bra.b   \topexact
  348.  
  349. \sameline
  350.         cq      d2
  351.         mw      _noteboxleft,d2
  352.         cq      d3
  353.         mw      _noteboxtop,d3
  354.         cq      d4
  355.         bra     \drawcenter
  356.  
  357. \topblank
  358.         cq      d3                      ; Top part of box is blank
  359. \topblankloop
  360.         ml      d3,(a1)+
  361.         ml      d3,(a1)+
  362.         ml      d3,(a1)+
  363.         ml      d3,(a1)+
  364.         add.w   d4,a1
  365.         subq.w  #1,d2
  366.         addq.w  #1,d0
  367.         bnz.b   \topblankloop
  368.  
  369. \topexact
  370.         mq      #$55,d5
  371.         mw      #$fff,d6
  372. \loop                                   ; Copy the note table straight to the display
  373.         subq.w  #1,d1
  374.         bmi.b   \botblank
  375.         dolong
  376.         dolong
  377.         dolong
  378.         dolong
  379.         add.w   d4,a1
  380.         add.w   scrollmod(a4),a0
  381.         dbra    d2,\loop
  382.         bra.b   \blit
  383.  
  384. \botblank                               ; Exhausted the note table, still more display
  385.         cq      d3
  386. \botblankloop
  387.         ml      d3,(a1)+
  388.         ml      d3,(a1)+
  389.         ml      d3,(a1)+
  390.         ml      d3,(a1)+
  391.         add.w   d4,a1
  392.         dbra    d2,\botblank
  393.  
  394. \blit
  395.         mq      #-1,d7
  396.  
  397.         lea     notebitmap,a0           ; Copy the new scope display
  398.         cq      d0
  399.         cq      d1
  400.         ml      _noterastport,a1
  401.         mb      #1,rp_Mask(a1)
  402.         cq      d2
  403.         mw      _noteboxleft,d2
  404.         cq      d3
  405.         mw      _noteboxtop,d3
  406.         cq      d4
  407.         mw      #NOTEWIDTH,d4
  408.         mq      #NOTEHEIGHT,d5
  409.         mw      #$0c0,d6
  410.         jl      BltBitMapRastPort
  411.  
  412. \drawcenter
  413.         ml      _noterastport,a1        ; Draw the center line
  414.         mb      #2,rp_Mask(a1)
  415.         ml      d2,d0
  416.         ml      d3,d1
  417.         add.w   #NOTEHEIGHT/2-1,d1
  418.         add.w   #NOTEWIDTH-1,d2
  419.         add.w   #NOTEHEIGHT/2+1,d3
  420.         jmp     _LVORectFill(a6)
  421.  
  422.         data    __MERGED
  423.  
  424. _flashytask     dc.l    0,0
  425.                 dc.b    NT_TASK,-5
  426.                 dc.l    flashyname
  427.                 ds.b    TC_SPREG-TC_FLAGS
  428.                 dc.l    0
  429.                 dc.l    stacklower
  430.                 dc.l    stackupper
  431.                 dc.l    0,0
  432.                 dc.l    _flashytask+TC_MEMENTRY+LH_TAIL
  433.                 dc.l    0
  434.                 dc.l    _flashytask+TC_MEMENTRY+LH_HEAD
  435.                 ds.b    TC_SIZE-(TC_MEMENTRY+12)
  436.  
  437. spectrumbitmap  dc.w    SPECTRUMWIDTH/8
  438.                 dc.w    SPECTRUMHEIGHT
  439.                 dc.b    0
  440.                 dc.b    2
  441.                 dc.w    0
  442.                 dc.l    specplane0,specplane1
  443.  
  444. scopebitmap     dc.w    SCOPEWIDTH/8
  445.                 dc.w    SCOPEHEIGHT
  446.                 dc.b    0
  447.                 dc.b    1
  448.                 dc.w    0
  449.                 dc.l    scopeplane
  450.  
  451. notebitmap      dc.w    NOTEWIDTH/8
  452.                 dc.w    NOTEHEIGHT
  453.                 dc.b    0
  454.                 dc.b    1
  455.                 dc.w    0
  456.                 dc.l    noteplane
  457.  
  458. flashyname      dc.b    "MultiPlayer Flashy Windows",0
  459.  
  460.         bss     __MERGED
  461.  
  462. _scopeinterval  ds.l    1               ; Audio intervals per flash frame
  463.  
  464. _flashytaskptr  ds.l    1               ; Pointer to _flashytask if active
  465.  
  466. scopechandata   ds.b    scd_SIZEOF*4    ; Scope channel data
  467.  
  468. notetab         ds.l    1               ; Stuff for note scroller
  469. scrollmod       ds.w    1
  470. scrolllines     ds.w    1
  471. scrollline      ds.w    1
  472. oldscrollline   ds.w    1
  473.  
  474. _flashactive    ds.b    1               ; Flashy window is clear and inactive
  475.  
  476.                 ds.b    1               ; Padding on left
  477.                 even
  478. _spectrum       ds.b    SPECTRUMRES     ; Spectrum of volumes
  479.                 ds.b    1               ; Padding on right
  480.  
  481.                 cnop    0,4
  482.  
  483. stacklower
  484.                 ds.b    FLASHYSTACKSIZE
  485. stackupper
  486.  
  487. _flashysem      ds.b    SS_SIZE         ; Semaphore for starting/stopping flashytask
  488.  
  489. zeros           ds.b    SCOPEWIDTH
  490.  
  491.         bss     chip,chip
  492.  
  493. specplane0      ds.b    SPECTRUMWIDTH/8*SPECTRUMHEIGHT
  494. scopeplane      ds.b    SCOPEWIDTH/8*SCOPEHEIGHT
  495. noteplane       ds.b    NOTEWIDTH/8*NOTEHEIGHT
  496. specplane1      ds.b    SPECTRUMWIDTH/8*SPECTRUMHEIGHT
  497.  
  498.         end
  499.